<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>管理员界面</title>
    <link type="text/css" rel="stylesheet" href="static/css/style.css">
    <script type="text/javascript" src="static/js/jquery-3.3.1.min.js"></script>
    <script type="text/javascript">
        $(function () {
            // 跳到指定的页码
            $("#addDoctor").click(function () {
                $.ajax({
                    type: "POST",
                    url: "/hospital/mangerServlet?action=add", success: function () {
                        location.href = "/hospital/mangerServlet?action=page"
                    }
                });
            });
            $("a.deleteItem").click(function () {
                return confirm("你确定要删除【" + $(this).parent().parent().find(".doctor_name .sp2").text() + "】吗?")
            });
            $("#logout").click(function () {
                location.href = "/hospital/mangerServlet?action=logout"
            })
        });
    </script>
</head>
<body>
<div id="header">
    <div>
        <button id="addDoctor">添加医生</button>
        <button id="logout">注销</button>&nbsp;&nbsp;
    </div>
</div>
<div id="main">
    <form action="/hospital/mangerServlet?action=page" id="mPage" method="post">
        <c:forEach items="${requestScope.page.items}" var="doctor">
            <div class="d_list">
                <c:choose>
                    <c:when test="${doctor.sex=='女'}">
                        <div class="img_div">
                            <img class="doctor_img" alt="" src="static/img/doctor.jpeg"/>
                        </div>
                    </c:when>
                    <c:otherwise>
                        <div class="img_div">
                            <img class="doctor_img" alt="" src="static/img/doctor1.jpg"/>
                        </div>
                    </c:otherwise>
                </c:choose>
                <div class="doctor_info">
                    <div class="doctor_name">
                        <span class="sp1">医生名字:</span>
                        <span class="sp2">${doctor.name}</span>
                    </div>
                    <div class="doctor_age">
                        <span class="sp1">医生年龄:</span>
                        <span class="sp2">${doctor.age}</span>
                    </div>
                    <div class="doctor_department">
                        <span class="sp1">所在科室:</span>
                        <span class="sp2">${doctor.department}</span>
                    </div>
                    <div class="doctor_profile">
                        <span class="sp1">个人简介:</span>
                        <span class="sp2">${doctor.profile}</span>
                    </div>
                    <div class="doctor_delete">
                        <button>
                            <a class="deleteItem" href="/hospital/mangerServlet?action=delete&id=${doctor.id}">删除</a>
                        </button>
                    </div>

                </div>
            </div>
        </c:forEach>

    </form>
    <%--静态包含分页条--%>
    <%@include file="/pages/manager/page_nav.jsp" %>
</div>
</body>
</html>
